package com.example.materialviewpagerdemo.util;

import android.os.Handler;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;

public class Sendcommand implements Runnable {

    private Handler handler;
    private String command;
    private Socket socket;
    private OutputStream outputStream;
    private  PrintStream ps;

    public Sendcommand(String command) {
        super();
        this.command = command;
    }

    @Override
    public void run() {

        try {
           socket = new Socket("202.194.139.41", 6000);
            outputStream = socket.getOutputStream();
            outputStream.write(command.toString().getBytes("utf-8"));
            //ps=new PrintStream(socket.getOutputStream());
            //ps.print(command);

            System.out.println(".%%%%%%"+(command.toString().getBytes("utf-8")).toString()+"&&&&&&&&"+command);
        } catch (Exception e) {
            // TODO: handle exception
            try {
                outputStream.close();
                socket.close();
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        } finally {
            try {
                outputStream.close();
                socket.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }

}
